package hc.j2me;

import hc.core.IConstant;
import hc.core.util.ByteUtil;
import hc.j2me.util.J2MEHttpUtil;

public class J2MEConstant extends IConstant {
	public static int SPLIT_MAX_SIZE = 110;
	public static final String IS_SIMU = "IsSimu";
	
	public int getInt(String p) {
		if(p == IConstant.BizServerSplitMaxSize){
			return SPLIT_MAX_SIZE;
		}else if(p == IConstant.IS_J2ME){
			return 1;
		}
		return 30;
	}
	
	/**
	 * 有可能为空
	 */
    public final String getAjax(String url){
    	return J2MEHttpUtil.getAjax(url);
    }
    
    /**
     * 有可能为空
     */
    public final String getAjaxForSimu(String url, boolean isTCP){
    	return J2MEHttpUtil.getAjaxForSimu(url, false);
    }

	public boolean getBoolean(String p){
		if(p == IS_SIMU){
			return false;
		}
		
		return false;
	}

	public Object getObject(String p) {
		if(p == IConstant.CertKey){
			return ByteUtil.decodeBase64(Starter.config.certKey);
		}else{
			return Starter.properties.get(p);
		}
	}

	public void setObject(String key, Object value) {
		if(key == IConstant.CertKey){
			byte[] bs = (byte[])value;
			
			Starter.config.certKey = ByteUtil.encodeBase64(bs);
			Starter.update(Starter.config);
		}
	}
}
